package org.prem.hibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class Main10 {

	public static void main(String args[]){
		StudentAddress10 studentAddress10_1 = new StudentAddress10();
		studentAddress10_1.setAddress_detail("Chennai, India");
		
		Student10 student10_1 = new Student10();
		student10_1.setStudent_name("Prem");
		student10_1.setStudentAddress10(studentAddress10_1);
		
		Student10 student10_2 = new Student10();
		student10_2.setStudent_name("Kumar");
		student10_2.setStudentAddress10(studentAddress10_1);
		
		StudentAddress10 studentAddress10_2 = new StudentAddress10();
		studentAddress10_2.setAddress_detail("Chicago, USA");
		
		Student10 student10_3 = new Student10();
		student10_3.setStudent_name("PremUS");
		student10_3.setStudentAddress10(studentAddress10_2);
		
		Student10 student10_4 = new Student10();
		student10_4.setStudent_name("KumarUS");
		student10_4.setStudentAddress10(studentAddress10_2);
		
		SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
		Session session = sessionFactory.openSession();
		session.beginTransaction();
		
		session.save(student10_1);
		session.save(student10_2);
		session.save(student10_3);
		session.save(student10_4);
		
		session.getTransaction().commit();
		session.close();
		sessionFactory.close();
		
	}

}
